package com.sg.tr.service;

import java.sql.Timestamp;
import java.text.NumberFormat;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.apache.http.entity.StringEntity;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.alibaba.druid.sql.ast.SQLObject;
import com.alibaba.fastjson.JSONArray;
import com.sg.common.dao.BaseDao;
import com.sg.common.empty.core.FilterVal;
import com.sg.common.empty.service.CfgService;
import com.sg.common.utils.Constant;
import com.sg.common.utils.DateTimeUtils;
import com.sg.common.utils.ReUtils;
import com.sg.tr.entity.Resum;
@Component
public class TrMobService extends BaseDao{

	private Logger logger = Logger.getLogger(getClass());
	
	@Autowired
	CfgService service;
	
	/**
	 * 培训小结增加
	 * @param sum
	 * @param attach
	 * @param actualId
	 * @param code
	 * @param name
	 */
	@Transactional
	public void sumAdd(Object sum, Object attach, Object actualId, Object code,
			Object name) {
		String nid = (String) FilterVal.init("sys32Id", service).get2();
		String createDate = DateTimeUtils.formatDate(
				new Timestamp(System.currentTimeMillis()), "yyyy-MM-dd HH:mm");
		String insertSql = "insert into tr_sum (id, actual, code, name, sum, attach, createDate) values( ?, ?, ?, ?, ?, ?, ?)";
		service.excuteBySql(insertSql, new Object[]{nid, actualId, code, name, sum, attach, createDate});
//		service.excuteBySql(insertSql, new Object[]{nid, actualId, code, name, sum, JSONArray.toJSONString(attach), createDate});
		
		String res = "students,sumNo";
		String querySql = "select students,sumNo from tr_actual where id = ?";
		List<Map<String, Object>> actualList = service.queryBySqlToMap(querySql, new Object[]{actualId}, res.split(","));
		
		Map<String, Object> actual = actualList.get(0);
		JSONArray jsonArray=JSONArray.parseArray(actual.get("students").toString());
		Object[] students = jsonArray.toArray();
		Object sumNoO = actual.get("sumNo");
		if(sumNoO!=null){
			//记录新增
			JSONArray sumNoArray=JSONArray.parseArray(sumNoO.toString());
			Object[] sumNo = sumNoArray.toArray();
			List<Object> sumNoList = new ArrayList<Object>();
			  for (int i=0; i<sumNo.length; i++) {
				  sumNoList.add(sumNo[i]);
		        }
			  sumNoList.add(sumNo.length, code +"-" +name); 
			  Object[] sumNoAdd = sumNoList.toArray();
			  if(sumNoAdd.length==students.length){
				  String upActualSql = "update tr_actual set sumNo=?,sumRe=? where id=?";
				  service.excuteBySql(upActualSql, new Object[]{ JSONArray.toJSONString(sumNoAdd),"1", actualId});
			  }else{
				  String upActualSql = "update tr_actual set sumNo=? where id=?";
				  service.excuteBySql(upActualSql, new Object[]{ JSONArray.toJSONString(sumNoAdd), actualId});
			  }
			 
		}else{
			//第一个人小结提交
			Object[] sumNo = new Object[]{code +"-" + name};
			String upSql = "update tr_actual set sumNo=? where id=?";
			service.excuteBySql(upSql, new Object[]{ JSONArray.toJSONString(sumNo), actualId});
		}
	}

	/**
	 * 培训反馈填写及培训实际更新
	 * @param rele
	 * @param sub
	 * @param cour
	 * @param expe
	 * @param easy
	 * @param smoo
	 * @param mode
	 * @param appl
	 * @param pre
	 * @param cle
	 * @param work
	 * @param help
	 * @param part
	 * @param exer
	 * @param judg
	 * @param wort
	 * @param disl
	 * @param adju
	 * @param code
	 * @param name
	 * @param actualId
	 */
	@Transactional
	public void fdAdd(Object rele, Object sub, Object cour, Object expe,
			Object easy, Object smoo, Object mode, Object appl, Object pre,
			Object cle, Object work, Object help, Object part, Object exer,
			Object judg, Object wort, Object disl, Object adju, Object code,
			Object name, String actualId) {
		String nid = (String) FilterVal.init("sys32Id", service).get2();
		String createDate = DateTimeUtils.formatDate(
				new Timestamp(System.currentTimeMillis()), "yyyy-MM-dd HH:mm");
		String insertSql = "insert into tr_fd (id, actual, code, name, rele, sub, cour, expe, easy, smoo, mode, appl, pre, cle, work, help, part, exer, judg, wort, disl, adju, createDate) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
		service.excuteBySql(insertSql, new Object[]{nid, actualId, code, name, rele, sub, cour, expe, easy, smoo, mode, appl, pre, cle, work, help, part, exer, judg, wort, disl, adju, createDate });
		
		String res = "students,fdNo";
		String querySql ="select students,fdNo from tr_actual where id=?";
		List<Map<String, Object>> actualList = service.queryBySqlToMap(querySql, new Object[]{actualId}, res.split(","));
		
		Map<String, Object> actual = actualList.get(0);
		JSONArray studentsArray=JSONArray.parseArray(actual.get("students").toString());
		Object[] students = studentsArray.toArray();
		Object fdNoOld = actual.get("fdNo");
		if(fdNoOld!=null){
			//记录新增
			JSONArray fdNoArray=JSONArray.parseArray(fdNoOld.toString());
//			已完成培训反馈信息填写人员
			Object[] fdNo = fdNoArray.toArray();
			List<Object> fdNoList = new ArrayList<Object>();
			  for (int i=0; i<fdNo.length; i++) {
				  fdNoList.add(fdNo[i]);
		        }
//			  增加当前完成人员信息
			  fdNoList.add(fdNo.length, code+"-"+name); 
			  Object[] fdNoAdd = fdNoList.toArray();
			  if(fdNoAdd.length==students.length){
				  String upActualSql = "update tr_actual set fdNo=?,fdRe=? where id=?";
				  service.excuteBySql(upActualSql, new Object[]{ JSONArray.toJSONString(fdNoAdd),"1", actualId});
			  }else{
				  String upActualSql = "update tr_actual set fdNo=? where id=?";
				  service.excuteBySql(upActualSql, new Object[]{ JSONArray.toJSONString(fdNoAdd), actualId});
			  }
			 
		}else{
			Object[] fdNo = new Object[]{code +"-" + name};
			String upSql = "update tr_actual set fdNo=? where id=?";
			service.excuteBySql(upSql, new Object[]{ JSONArray.toJSONString(fdNo), actualId});
		}
	}
	
	/**
	 * 更新tr_reg(签到详细清单)及tr_actual中regNo属性
	 * @param actualId
	 * @param code
	 * @param name
	 */
	@Transactional
	public synchronized void  signAuto(String actualId, String code, String name) {
		String upRegSql= "update tr_reg set enable=? ,regDate=? where code=? and name=? and actual=?";
		String now = DateTimeUtils.formatDate(
				new Timestamp(System.currentTimeMillis()), "yyyy-MM-dd HH:mm");
		service.excuteBySql(upRegSql, new Object[]{'1', now,code,name,actualId});
		
		updateActual(actualId, code, name);
	}

	/**
	 * 更新tr_actual表格中签到信息---regNo属性和leftNo属性
	 * @param actualId
	 * @param code
	 * @param name
	 */
	public synchronized void updateActual(String actualId, String code, String name) {
		String res = "students,regNo,leftNo";
		String sql = "SELECT tr.students, tr.regNo, tr.leftNo from tr_actual tr where tr.enable='0' and id=?";
		List<Map<String, Object>> actualList = service.queryBySqlToMap(sql, new Object[]{actualId}, res.split(","));
		
		Map<String, Object> actual = actualList.get(0);
		Object oldRegNo = actual.get("regNo");  //2019-10-12 标记.原已签到人员信息
		Object leftNo = actual.get("leftNo");	//原未签到人员信息
		JSONArray allStud = JSONArray.parseArray(leftNo.toString());
		Object[] allStudList = allStud.toArray();	//未签到人员
		List<Object> leftNoList = new ArrayList<>();  //原未签到人员信息List
		for(int l=0;l<allStudList.length;l++){				//遍历原未签到人员信息，如不包含当前签到人员，增加至leftNoList
			if(!StringUtils.equals(allStudList[l].toString(), code+"-"+name)){
				leftNoList.add(allStudList[l]);
			}
		}
		
//			第一人签到/后续其他人员签到,更新actual表格中regNo属性
		if(oldRegNo==null||StringUtils.isBlank(oldRegNo.toString())){ 				
			System.out.println("无任何签到信息");
			Object[] signUser = new Object[]{code + "-" + name};
			String upActualSql = "update tr_actual set regNo = ?,leftNo=? where id= ?";
			service.excuteBySql(upActualSql, new Object[]{ JSONArray.toJSONString(signUser), JSONArray.toJSONString(leftNoList), actualId});
		}else{
			JSONArray regStud = JSONArray.parseArray(oldRegNo.toString());
			Object[] regStudList = regStud.toArray();
			List<Object> addRegNo = new ArrayList<Object>();
			for(int m=0;m<regStudList.length;m++){
				addRegNo.add(regStudList[m]);
			}
			addRegNo.add(regStudList.length, code+"-"+name);
			Object[] regNo = addRegNo.toArray();
			String upActualSql = "update tr_actual set regNo =?,leftNo=? where id=?";
			service.excuteBySql(upActualSql, new Object[]{JSONArray.toJSONString(regNo), JSONArray.toJSONString(leftNoList), actualId});
		}
	}
	
	/**
	 * 后台更新tr_actual及tr_reg信息,插入tosend推送钉钉签到信息
	 * @param requestBody
	 * @param actualId
	 * @param name
	 * @param code
	 */
	@Transactional
	public void initSign(Map<String, Object> requestBody) {
		
		String actualId = requestBody.get("actualId").toString();
		String name = requestBody.get("name").toString();
		String code = requestBody.get("code").toString();
		String now = DateTimeUtils.formatDate(
				new Timestamp(System.currentTimeMillis()), "yyyy-MM-dd HH:mm");
		String actQuerySql = "select tr.date, tr.time,tr.item from tr_actual tr where id=?";
		String actualRes= "date,time,item";
		List<Map<String, Object>> actList = service.queryBySqlToMap(actQuerySql, new Object[]{actualId},actualRes.split(","));
		
		Map<String, Object> act = actList.get(0);
		String date = act.get("date").toString();
		String time = act.get("time").toString();
		String item = act.get("item").toString();
		
		Object checklist = requestBody.get("checklist");
		if(checklist!=null){
			List<String> temp = Constant.getRbList(requestBody,"checklist");
			checklist= JSONArray.toJSONString(temp);
//			发出钉钉签到信息
			JSONArray checkArray = JSONArray.parseArray(checklist.toString());
			Object[] checkList = checkArray.toArray();
			for(int j=0;j<checkList.length;j++){
				 String stuCode = checkList[j].toString().substring(0, 6);
//				 String stuName = checkList[j].toString().substring(7);
//				 2020-01-09 阿里云部署项目整体迁移至47.92.54.167
				 String url = "http://47.92.54.167:8080/pmmt/#/mhome/register?eventId="+actualId+"&code="+stuCode;	//阿里云8082测试环境,8083正式环境
//				 String url = "http://120.55.90.195:8083/pmmt/#/mhome/register?eventId="+actualId+"&code="+stuCode;	//阿里云8082测试环境,8083正式环境
//				 String url = "http://10.10.156.173:8080/pmmt/#/home/register?eventId="+actualId+"&code="+stuCode;	//云桌面测试环境
				 String content = "{\"title\":\"培训台账签到提醒\",\"text\":\"信息化系统-电子培训台账系统-签到信息  \n  您好!   \n  您有于"
						 +date +"," +time +"开始的关于<<" +item +">>" +"的培训签到提醒,请及时签到    \n  [手机客户端点我进入]("
						 		+ url+ ")\"}";
				 String insertToSendSql = "insert into tosend (date,time,content,state,type,userid,partyid,status,msgtype,inserttime) "
				 		+ "values('','','" + content + "','1','培训台账签到提醒','" + stuCode + "','','notsent','markdown','" 
				 		+now + "')";
				 service.excuteBySql(insertToSendSql);
			}
			
			String res = "students,sendReg";
			String sql = "SELECT tr.students, tr.sendReg from tr_actual tr where tr.enable='0' and id=?";
			List<Map<String, Object>> actualList = service.queryBySqlToMap(sql, new Object[]{actualId}, res.split(","));
			Map<String, Object> actual = actualList.get(0);
			Object sendReg = actual.get("sendReg");
		
			
//				sendReg是否已发送签到验证属性,等于1表示已完成一次发送,
//			其余情况为未发送,需根据students信息逐条发送
			if(sendReg==null||!StringUtils.equals(sendReg.toString(), "1")){
//					更新tr_actual表中sendReg属性,并遍历该表格中students属性生成tr_reg(签到详细情况)
				Object students = actual.get("students");
				String upActualSql = "update tr_actual set sendReg=?,leftNo=? where id=?";
				service.excuteBySql(upActualSql, new Object[]{"1",students,actualId});
				
				JSONArray studentsArray=JSONArray.parseArray(students.toString());
				Object[] studentsList = studentsArray.toArray();
				  for (int i=0; i<studentsList.length; i++) {
					  String stuCode = studentsList[i].toString().substring(0, 6);
					  String stuName = studentsList[i].toString().substring(7);
					  String nid = (String) FilterVal.init("sys32Id", service).get2();
					  String regSql = "insert into tr_reg (id, actual, name, code, enable, createDate, createName, createCode) values (?,?,?,?,?,?,?,?)";
					  service.excuteBySql(regSql, new Object[]{nid, actualId, stuName, stuCode, "0", now, name, code});
				  }
			}
			
		}
	
	}
	
	/**
	 * 定时任务,每天根据(工号/岗位)信息查询个人培训统计数据,并插入或更新至tr_resum表中
	 * @return
	 * @throws Exception
	 */
	public void getCourseSta () throws Exception{
		List<Map<String, Object>> memberList = Constant.MEMBERDATA;
		List<Map<String, Object>> actualList = Constant.ACTUALDATA;
		List<Map<String, Object>> personalList = Constant.PERSONALDATA;
		List<Map<String, Object>> clstList = Constant.CLSTDATA;
		
	    List<Resum> resumSaveList = new ArrayList<Resum>();
		
		for(Map<String, Object> member : memberList){
			String code = member.get("memberCode").toString();
			String name = member.get("name").toString();
			String postDescr = member.get("postDescr").toString();			//岗位描述	
			String pocaDescr = member.get("pocaDescr").toString();			//岗位性质描述
			
			int classNum = 0;		//总数量
			int finishedClassNum = 0;		//已完成数量
			int finishedStHour = 0;		//已完成标准课时
			int finishedUnStHour = 0;	//已完成非标准课时
			int unFinishedStHour = 0;		//未完成标准课时
			int unFinishedUnStHour = 0;	//未完成非标准课时
			Map<String, Object> sumYearNumMap = new HashMap<String, Object>();   // 分年度统计培训次数
			Map<String, Object> sumYearHourMap = new HashMap<String, Object>();  	//	分年度统计培训课时
			
			int finishedPrimaryNum = 0;	  		//已参加的初级标准课程数量			
			int finishedMiddleNum = 0;			//已参加的中级
			int finishedSeniorNum = 0;			//已参加的高级
			int finishedArtificerNum = 0;			//已参加的技师
			int finishedSeniorArtificerNum = 0;			//已参加的高级技师
			
			double finishedPrimaryHour = 0;			//已参加的初级标准课程课时
			double finishedMiddleHour = 0;			//中级课时
			double finishedSeniorHour = 0;			//高级课时
			double finishedArtificerHour = 0;			//技师课时
			double finishedSeniorArtificerHour = 0;			//高级技师课时
			
			int primaryClassNum = 0;	  		//标准课程体系中的初级标准课程数量			
			int middleClassNum = 0;			//标准课程体系中的中级
			int seniorClassNum = 0;			//标准课程体系中的高级
			int artificerClassNum = 0;			//标准课程体系中的技师
			int seniorArtificerClassNum = 0;			//标准课程体系中的高级技师
			
			double primaryHour = 0;	  		//标准课程体系中的初级标准课程课时数量			
			double middleHour = 0;			//标准课程体系中的中级
			double seniorHour = 0;			//标准课程体系中的高级
			double artificerHour = 0;			//标准课程体系中的技师
			double seniorArtificerHour = 0;			//标准课程体系中的高级技师
			
		    String primaryNumCompRate;			//初级课程完成率
	    	String middleNumCompRate;			//中级课程完成率
	    	String seniorNumCompRate;			//高级完成率
	    	String artificerNumCompRate;
	    	String seniorArtificerNumCompRate;
	    	
	    	String primaryHourCompRate;			//初级课程完成率
		    String middleHourCompRate;			//中级课程完成率
		    String seniorHourCompRate;			//高级完成率
		    String artificerHourCompRate;
		    String seniorArtificerHourCopmRate;
			
			for(Map<String, Object> actual : actualList){
//				int k = 0;
//				遍历培训记录，查询培训（总数/已完成）数量
				if(actual.get("students").toString().contains(code)){
					classNum++;
//					enable:  0,未完成；1，已完成；-1，取消
					if(StringUtils.equals(actual.get("enable").toString(), "1")){
						
//						分年度统计培训次数
						String year = StringUtils.left(actual.get("date").toString(), 4);
						if(sumYearNumMap.get(year) == null){
							sumYearNumMap.put(year, 1);
						}else{
							int num =  Integer.parseInt(sumYearNumMap.get(year).toString());
							sumYearNumMap.put(year, num+1);
						}
						
//						统计标准课时与非标准课时总课时
						if(actual.get("hour2") == null||StringUtils.isBlank(actual.get("hour2").toString())){		//？？？非标准课时
							if(StringUtils.isNotBlank(actual.get("hour").toString())){
								finishedUnStHour += Double.parseDouble(actual.get("hour").toString());
								if(sumYearHourMap.get(year) == null){
									sumYearHourMap.put(year, Double.parseDouble(actual.get("hour").toString()));
								}else{
									double hour = Double.parseDouble(sumYearHourMap.get(year).toString());
									sumYearHourMap.put(year, hour+Integer.parseInt(actual.get("hour").toString()));
								}
							}
						}else{
							finishedStHour += Double.parseDouble(actual.get("hour2").toString());		//标准课时
							if(sumYearHourMap.get(year) == null){
								sumYearHourMap.put(year, Double.parseDouble(actual.get("hour2").toString()));
							}else{
								double hour = Double.parseDouble(sumYearHourMap.get(year).toString());
								sumYearHourMap.put(year, hour+Double.parseDouble(actual.get("hour2").toString()));
							}
						}
						finishedClassNum++;
					}else{			//统计未完成课程的课时和  tr_actual,hour,非标准课时,手写输入;hour2,标准课程课时
						if(actual.get("hour2") == null||StringUtils.isBlank(actual.get("hour2").toString())){		//？？？非标准课时
							if(StringUtils.isNotBlank(actual.get("hour").toString())){
								unFinishedUnStHour += Double.parseDouble(actual.get("hour").toString());		
							}
						}else{																				//标准课时
							unFinishedStHour += Double.parseDouble(actual.get("hour2").toString());
						}
					}
				}
			}
		
//			遍历个人标准课程培训记录，查询对应岗位各等级培训数量、培训课时
//			tr_personal hour,累计课时;hour2,培训手写输入课时
			for(Map<String, Object> personal : personalList){
				if(StringUtils.equals(code, personal.get("epnum").toString())&&StringUtils.equals(pocaDescr, personal.get("tyds").toString())){
					if(personal.get("level").toString().contains("初级")||personal.get("level").toString().contains("岗前培训")){
						finishedPrimaryNum++;
						finishedPrimaryHour += Double.parseDouble(personal.get("hour").toString());
					}else if (StringUtils.equals(personal.get("level").toString(),"中级")){
						finishedMiddleNum++;
						finishedMiddleHour += Double.parseDouble(personal.get("hour").toString());
					}else if (StringUtils.equals(personal.get("level").toString(),"高级")){
						finishedSeniorNum++;
						finishedSeniorHour += Double.parseDouble(personal.get("hour").toString());
					}else if (StringUtils.equals(personal.get("level").toString(),"技师")){
						finishedArtificerNum++;
						finishedArtificerHour += Double.parseDouble(personal.get("hour").toString());
					}else if (StringUtils.equals(personal.get("level").toString(),"高级技师")){
						finishedSeniorArtificerNum++;
						finishedSeniorArtificerHour += Double.parseDouble(personal.get("hour").toString());;
					}
				}
			}
//			遍历标准课程，统计该岗位对应的各等级(初级、中级、高级、技师、高级技师)对应的课程数量及课时数量
//			????需要考虑课时为“/”时的统计
			for(Map<String, Object> clst : clstList){
				if(StringUtils.equals(clst.get("tyds").toString(), pocaDescr)){
					if(clst.get("level").toString().contains("初级")||clst.get("level").toString().contains("岗前培训")){
						primaryClassNum++;
						if(!StringUtils.equals(clst.get("hour").toString(), "/")){
							primaryHour += Double.parseDouble(clst.get("hour").toString());
						}
					}else if (StringUtils.equals(clst.get("level").toString(),"中级")){
						middleClassNum++;
						if(!StringUtils.equals(clst.get("hour").toString(), "/")){
							middleHour += Double.parseDouble(clst.get("hour").toString());
						}
					}else if (StringUtils.equals(clst.get("level").toString(),"高级")){
						seniorClassNum++;
						if(!StringUtils.equals(clst.get("hour").toString(), "/")){
							seniorHour += Double.parseDouble(clst.get("hour").toString());
						}
					}else if (StringUtils.equals(clst.get("level").toString(),"技师")){
						artificerClassNum++;
						if(!StringUtils.equals(clst.get("hour").toString(), "/")){
							artificerHour += Double.parseDouble(clst.get("hour").toString());
						}
					}else if (StringUtils.equals(clst.get("level").toString(),"高级技师")){
						seniorArtificerClassNum++;
						if(!StringUtils.equals(clst.get("hour").toString(), "/")){
							seniorArtificerHour += Double.parseDouble(clst.get("hour").toString());
						}
					}
				}
			}
			
//			各等级课程数量完成率
			NumberFormat format = NumberFormat.getPercentInstance();
	        format.setMaximumFractionDigits(2);//设置保留几位小数
	    
			primaryNumCompRate = calCompRate(finishedPrimaryNum, primaryClassNum, format);
			middleNumCompRate = calCompRate(finishedMiddleNum, middleClassNum, format);
			seniorNumCompRate = calCompRate(finishedSeniorNum, seniorClassNum, format);
			artificerNumCompRate= calCompRate(finishedArtificerNum, artificerClassNum, format);
			seniorArtificerNumCompRate = calCompRate(finishedSeniorArtificerNum, seniorArtificerClassNum, format);
			
//			岗位课程完成率相加
//			Number m = format.parse(source);
//			double dd = m.doubleValue();
			double sumNumRate = 0;
			sumNumRate = calSumRate(primaryNumCompRate, format, sumNumRate);
			sumNumRate = calSumRate(middleNumCompRate, format, sumNumRate);
			sumNumRate = calSumRate(seniorNumCompRate, format, sumNumRate);
			sumNumRate = calSumRate(artificerNumCompRate, format, sumNumRate);
			sumNumRate = calSumRate(seniorArtificerNumCompRate, format, sumNumRate);
			
				primaryHourCompRate = calCompRate(finishedPrimaryHour, primaryHour, format);
				middleHourCompRate = calCompRate(finishedMiddleHour, middleHour, format);
				seniorHourCompRate = calCompRate(finishedSeniorHour, seniorHour, format);
				artificerHourCompRate = calCompRate(finishedArtificerHour, artificerHour, format);
				seniorArtificerHourCopmRate = calCompRate(finishedSeniorArtificerHour, seniorArtificerHour, format);
			
//			各等级课程课时完成率和
				double sumHourRate = 0;
				sumHourRate = calSumRate(primaryHourCompRate, format, sumHourRate);
				sumHourRate = calSumRate(middleHourCompRate, format, sumHourRate);
				sumHourRate = calSumRate(seniorHourCompRate, format, sumHourRate);
				sumHourRate = calSumRate(artificerHourCompRate, format, sumHourRate);
				sumHourRate = calSumRate(seniorArtificerHourCopmRate, format, sumHourRate);
				
				String calDate = DateTimeUtils.formatDate(
						new Timestamp(System.currentTimeMillis()), "yyyy-MM-dd HH:mm");
	        String resumSql = "select ordInd,descr,value from tr_resum where  num=? and post =? and enable='1'";
	        String resumRes = "ordInd,descr,value";
	        
	        List<Map<String, Object>> resumList = service.queryBySqlToMap(resumSql, new Object[]{code, postDescr}, resumRes.split(","));
	       if(!resumList.isEmpty()){
	        	String delReSumSql = "delete from tr_resum where num=? and post=? and enable='1'";
	        	service.excuteBySql(delReSumSql, new Object[]{code, postDescr});
	        }				//	无记录时直接插入
	        
	
	      
	     /*课程统计信息*/
	     /* 序号1,参加培训总次数,*/
	      Resum re1  = new Resum();
	      re1.setKeyWord("course");
	      re1.setOrdInd(1);
	      re1.setNum(code);
	      re1.setName(name);
	      re1.setPost(postDescr);
	      re1.setDescr("参加培训总次数");
	      re1.setValue(String.valueOf(finishedClassNum));
	      re1.setEnable("1");
	      re1.setCalDate(calDate);
	      resumSaveList.add(re1);
	      /*序号2,年度培训总次数,*/
	      for(String key:sumYearNumMap.keySet()){
	    	  Resum re2  = new Resum();
  			Object value = sumYearNumMap.get(key);
  		      re2.setKeyWord("course");
  		      re2.setOrdInd(2);
  		      re2.setNum(code);
  		      re2.setName(name);
  		      re2.setPost(postDescr);
  		      re2.setDescr("年度培训总次数("+key+")");
  		      re2.setValue(String.valueOf(value));
  		      re2.setEnable("1");
  		      re2.setCalDate(calDate);
  		      resumSaveList.add(re2);
  		}
	      Resum re3 = new Resum();
	      re3.setKeyWord("course");
	      re3.setOrdInd(3);
	      re3.setNum(code);
	      re3.setName(name);
	      re3.setPost(postDescr);
	      re3.setDescr("初级标准课程完成率");
	      re3.setValue(String.valueOf(primaryNumCompRate));
	      re3.setEnable("1");
	      re3.setCalDate(calDate);
	      resumSaveList.add(re3);
	     
	      Resum re4 = new Resum();
	      re4.setKeyWord("course");
	      re4.setOrdInd(4);
	      re4.setNum(code);
	      re4.setName(name);
	      re4.setPost(postDescr);
	      re4.setDescr("中级标准课程完成率");
	      re4.setValue(String.valueOf(middleNumCompRate));
	      re4.setEnable("1");
	      re4.setCalDate(calDate);
	      resumSaveList.add(re4);
	      
	      Resum re5 = new Resum();
	      re5.setKeyWord("course");
	      re5.setOrdInd(5);
	      re5.setNum(code);
	      re5.setName(name);
	      re5.setPost(postDescr);
	      re5.setDescr("高级标准课程完成率");
	      re5.setValue(String.valueOf(seniorNumCompRate));
	      re5.setEnable("1");
	      re5.setCalDate(calDate);
	      resumSaveList.add(re5);
	      
	      Resum re6 = new Resum();
	      re6.setKeyWord("course");
	      re6.setOrdInd(6);
	      re6.setNum(code);
	      re6.setName(name);
	      re6.setPost(postDescr);
	      re6.setDescr("技师标准课程完成率");
	      re6.setValue(String.valueOf(artificerNumCompRate));
	      re6.setEnable("1");
	      re6.setCalDate(calDate);
	      resumSaveList.add(re6);
	      
	      Resum re7 = new Resum();
	      re7.setKeyWord("course");
	      re7.setOrdInd(7);
	      re7.setNum(code);
	      re7.setName(name);
	      re7.setPost(postDescr);
	      re7.setDescr("高级技师标准课程完成率");
	      re7.setValue(String.valueOf(seniorArtificerNumCompRate));
	      re7.setEnable("1");
	      re7.setCalDate(calDate);
	      resumSaveList.add(re7);
	      
	      Resum re8 = new Resum();
	      re8.setKeyWord("course");
	      re8.setOrdInd(8);
	      re8.setNum(code);
	      re8.setName(name);
	      re8.setPost(postDescr);
	      re8.setDescr("岗位标准课程完成率");
	      re8.setValue(String.valueOf(format.format(sumNumRate)));
	      re8.setEnable("1");
	      re8.setCalDate(calDate);
	      resumSaveList.add(re8);
	      
	      Resum re9 = new Resum();
	      re9.setKeyWord("course");
	      re9.setOrdInd(9);
	      re9.setNum(code);
	      re9.setName(name);
	      re9.setPost(postDescr);
	      re9.setDescr("初级标准课程未完成数");
	      re9.setValue(String.valueOf(primaryClassNum-finishedPrimaryNum));
	      re9.setEnable("1");
	      re9.setCalDate(calDate);
	      resumSaveList.add(re9);
	      
	      Resum re10 = new Resum();
	      re10.setKeyWord("course");
	      re10.setOrdInd(10);
	      re10.setNum(code);
	      re10.setName(name);
	      re10.setPost(postDescr);
	      re10.setDescr("中级标准课程未完成数");
	      re10.setValue(String.valueOf(middleClassNum-finishedMiddleNum));
	      re10.setEnable("1");
	      re10.setCalDate(calDate);
	      resumSaveList.add(re10);
	      
	      Resum re11 = new Resum();
	      re11.setKeyWord("course");
	      re11.setOrdInd(11);
	      re11.setNum(code);
	      re11.setName(name);
	      re11.setPost(postDescr);
	      re11.setDescr("高级标准课程未完成数");
	      re11.setValue(String.valueOf(seniorClassNum-finishedSeniorNum));
	      re11.setEnable("1");
	      re11.setCalDate(calDate);
	      resumSaveList.add(re11);
	      
	      Resum re12 = new Resum();
	      re12.setKeyWord("course");
	      re12.setOrdInd(12);
	      re12.setNum(code);
	      re12.setName(name);
	      re12.setPost(postDescr);
	      re12.setDescr("技师标准课程未完成数");
	      re12.setValue(String.valueOf(artificerClassNum-finishedArtificerNum));
	      re12.setEnable("1");
	      re12.setCalDate(calDate);
	      resumSaveList.add(re12);
	      
	      Resum re13 = new Resum();
	      re13.setKeyWord("course");
	      re13.setOrdInd(13);
	      re13.setNum(code);
	      re13.setName(name);
	      re13.setPost(postDescr);
	      re13.setDescr("高级技师标准课程未完成数");
	      re13.setValue(String.valueOf(seniorArtificerClassNum-finishedSeniorArtificerNum));
	      re13.setEnable("1");
	      re13.setCalDate(calDate);
	      resumSaveList.add(re13);
	      
	      Resum re14 = new Resum();
	      re14.setKeyWord("course");
	      re14.setOrdInd(14);
	      re14.setNum(code);
	      re14.setName(name);
	      re14.setPost(postDescr);
	      re14.setDescr("岗位标准课程未完成总数");
	      re14.setValue(String.valueOf((primaryClassNum-finishedPrimaryNum)+(middleClassNum-finishedMiddleNum)+(seniorClassNum-finishedSeniorNum)+(artificerClassNum-finishedArtificerNum)+(seniorArtificerClassNum-finishedSeniorArtificerNum)));
	      re14.setEnable("1");
	      re14.setCalDate(calDate);
	      resumSaveList.add(re14);
	      
	      Resum re15 = new Resum();
	      re15.setKeyWord("course");
	      re15.setOrdInd(15);
	      re15.setNum(code);
	      re15.setName(name);
	      re15.setPost(postDescr);
	      re15.setDescr("月度计划完成率");
	      re15.setValue(String.valueOf(format.format((double)finishedClassNum/classNum)));
	      re15.setEnable("1");
	      re15.setCalDate(calDate);
	      resumSaveList.add(re15);
	      
	      Resum re16 = new Resum();
	      re16.setKeyWord("course");
	      re16.setOrdInd(16);
	      re16.setNum(code);
	      re16.setName(name);
	      re16.setPost(postDescr);
	      re16.setDescr("月度计划未完成课程数量");
	      re16.setValue(String.valueOf(classNum-finishedClassNum));
	      re16.setEnable("1");
	      re16.setCalDate(calDate);
	      resumSaveList.add(re16);
	      
	      /*课时统计信息*/
	      Resum res1 = new Resum();
	      res1.setKeyWord("hour");
	      res1.setOrdInd(1);
	      res1.setNum(code);
	      res1.setName(name);
	      res1.setPost(postDescr);
	      res1.setDescr("培训总课时数");
	      res1.setValue(String.valueOf(finishedStHour+finishedUnStHour));
	      res1.setEnable("1");
	      res1.setCalDate(calDate);
	      resumSaveList.add(res1);
	      
	      for(String key:sumYearHourMap.keySet()){
  			Object value = sumYearHourMap.get(key);
  			 Resum res2 = new Resum();
  		      res2.setKeyWord("hour");
  		      res2.setOrdInd(2);
  		      res2.setNum(code);
  		      res2.setName(name);
  		      res2.setPost(postDescr);
  		      res2.setDescr("年度培训总课时数("+key+")");
  		      res2.setValue(String.valueOf(value));
  		      res2.setEnable("1");
  		      res2.setCalDate(calDate);
  		      resumSaveList.add(res2);
  		}
	      
	      Resum res3 = new Resum();
	      res3.setKeyWord("hour");
	      res3.setOrdInd(3);
	      res3.setNum(code);
	      res3.setName(name);
	      res3.setPost(postDescr);
	      res3.setDescr("初级标准课时完成率");
	      res3.setValue(String.valueOf(primaryHourCompRate));
	      res3.setEnable("1");
	      res3.setCalDate(calDate);
	      resumSaveList.add(res3);
	      
	      Resum res4 = new Resum();
	      res4.setKeyWord("hour");
	      res4.setOrdInd(4);
	      res4.setNum(code);
	      res4.setName(name);
	      res4.setPost(postDescr);
	      res4.setDescr("中级标准课时按成率");
	      res4.setValue(String.valueOf(middleHourCompRate));
	      res4.setEnable("1");
	      res4.setCalDate(calDate);
	      resumSaveList.add(res4);
	      
	      Resum res5 = new Resum();
	      res5.setKeyWord("hour");
	      res5.setOrdInd(5);
	      res5.setNum(code);
	      res5.setName(name);
	      res5.setPost(postDescr);
	      res5.setDescr("高级标准课时完成率");
	      res5.setValue(String.valueOf(seniorHourCompRate));
	      res5.setEnable("1");
	      res5.setCalDate(calDate);
	      resumSaveList.add(res5);
	      
	      Resum res6 = new Resum();
	      res6.setKeyWord("hour");
	      res6.setOrdInd(6);
	      res6.setNum(code);
	      res6.setName(name);
	      res6.setPost(postDescr);
	      res6.setDescr("技师标准课时完成率");
	      res6.setValue(String.valueOf(artificerHourCompRate));
	      res6.setEnable("1");
	      res6.setCalDate(calDate);
	      resumSaveList.add(res6);
	      
	      Resum res7 = new Resum();
	      res7.setKeyWord("hour");
	      res7.setOrdInd(7);
	      res7.setNum(code);
	      res7.setName(name);
	      res7.setPost(postDescr);
	      res7.setDescr("高级技师标准课时完成率");
	      res7.setValue(String.valueOf(seniorArtificerHourCopmRate));
	      res7.setEnable("1");
	      res7.setCalDate(calDate);
	      resumSaveList.add(res7);
	      
	      Resum res8 = new Resum();
	      res8.setKeyWord("hour");
	      res8.setOrdInd(8);
	      res8.setNum(code);
	      res8.setName(name);
	      res8.setPost(postDescr);
	      res8.setDescr("岗位标准课时完成率");
	      res8.setValue(String.valueOf(format.format(sumHourRate)));
	      res8.setEnable("1");
	      res8.setCalDate(calDate);
	      resumSaveList.add(res8);
	      
	      Resum res9 = new Resum();
	      res9.setKeyWord("hour");
	      res9.setOrdInd(9);
	      res9.setNum(code);
	      res9.setName(name);
	      res9.setPost(postDescr);
	      res9.setDescr("初级标准课时未完成数");
	      res9.setValue(String.valueOf((int)(primaryHour-finishedPrimaryHour)));
	      res9.setEnable("1");
	      res9.setCalDate(calDate);
	      resumSaveList.add(res9);
	      
	      Resum res10 = new Resum();
	      res10.setKeyWord("hour");
	      res10.setOrdInd(10);
	      res10.setNum(code);
	      res10.setName(name);
	      res10.setPost(postDescr);
	      res10.setDescr("中级标准课时未完成数");
	      res10.setValue(String.valueOf((int)(middleHour-finishedMiddleHour)));
	      res10.setEnable("1");
	      res10.setCalDate(calDate);
	      resumSaveList.add(res10);
	      
	      Resum res11 = new Resum();
	      res11.setKeyWord("hour");
	      res11.setOrdInd(11);
	      res11.setNum(code);
	      res11.setName(name);
	      res11.setPost(postDescr);
	      res11.setDescr("高级标准课时未完成数");
	      res11.setValue(String.valueOf((int)(seniorHour-finishedSeniorHour)));
	      res11.setEnable("1");
	      res11.setCalDate(calDate);
	      resumSaveList.add(res11);
	      
	      Resum res12 = new Resum();
	      res12.setKeyWord("hour");
	      res12.setOrdInd(12);
	      res12.setNum(code);
	      res12.setName(name);
	      res12.setPost(postDescr);
	      res12.setDescr("技师标准课时未完成数");
	      res12.setValue(String.valueOf((int)(artificerHour-finishedArtificerHour)));
	      res12.setEnable("1");
	      res12.setCalDate(calDate);
	      resumSaveList.add(res12);
	      
	      Resum res13 = new Resum();
	      res13.setKeyWord("hour");
	      res13.setOrdInd(13);
	      res13.setNum(code);
	      res13.setName(name);
	      res13.setPost(postDescr);
	      res13.setDescr("高级技师标准课时未完成数");
	      res13.setValue(String.valueOf((int)(seniorArtificerHour-finishedSeniorArtificerHour)));
	      res13.setEnable("1");
	      res13.setCalDate(calDate);
	      resumSaveList.add(res13);
	      
	      Resum res14 = new Resum();
	      res14.setKeyWord("hour");
	      res14.setOrdInd(14);
	      res14.setNum(code);
	      res14.setName(name);
	      res14.setPost(postDescr);
	      res14.setDescr("岗位标准课时总未完成数");
	      res14.setValue(String.valueOf((int)((primaryHour-finishedPrimaryHour)+(middleHour-finishedMiddleHour)+(seniorHour-finishedSeniorHour)+(artificerHour-finishedArtificerHour)+(seniorArtificerHour-finishedSeniorArtificerHour))));
	      res14.setEnable("1");
	      res14.setCalDate(calDate);
	      resumSaveList.add(res14);
	      
	      Resum res15 = new Resum();
	      res15.setKeyWord("hour");
	      res15.setOrdInd(15);
	      res15.setNum(code);
	      res15.setName(name);
	      res15.setPost(postDescr);
	      res15.setDescr("月度计划完成率");
	      res15.setValue(String.valueOf(format.format((double)(finishedStHour+finishedUnStHour)/(finishedStHour+finishedUnStHour+unFinishedStHour+unFinishedUnStHour))));
	      res15.setEnable("1");
	      res15.setCalDate(calDate);
	      resumSaveList.add(res15);
	      
	      Resum res16 = new Resum();
	      res16.setKeyWord("hour");
	      res16.setOrdInd(16);
	      res16.setNum(code);
	      res16.setName(name);
	      res16.setPost(postDescr);
	      res16.setDescr("月度计划未完成课程数量");
	      res16.setValue(String.valueOf(unFinishedStHour+unFinishedUnStHour));
	      res16.setEnable("1");
	      res16.setCalDate(calDate);
	      resumSaveList.add(res16);
	      
	    
	        
	        
	        	/*String insertResumSql = "insert into tr_resum (id, keyWord, num, name, post, ordInd, descr, value, enable, calDate) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
//				课程统计信息
	        	//        	String nId = (String) FilterVal.init("sys32Id", service).get2();
	        	service.excuteBySql(insertResumSql, new Object[]{(String) FilterVal.init("sys32Id", service).get2(), "course", code, name, pocaDescr, 1, "参加培训总次数", finishedClassNum, '1', calDate});
	        	for(String key:sumYearNumMap.keySet()){
	    			Object value = sumYearNumMap.get(key);
	    			service.excuteBySql(insertResumSql, new Object[]{(String) FilterVal.init("sys32Id", service).get2(), "course", code, name, pocaDescr, 2, "年度培训总次数("+key+")", value, '1', calDate});
	    		}
	        	service.excuteBySql(insertResumSql, new Object[]{(String) FilterVal.init("sys32Id", service).get2(), "course", code, name, pocaDescr, 3, "初级标准课程完成率", primaryNumCompRate, '1', calDate});
	        	service.excuteBySql(insertResumSql, new Object[]{(String) FilterVal.init("sys32Id", service).get2(), "course", code, name, pocaDescr, 4, "中级标准课程完成率", middleNumCompRate, '1', calDate});
	        	service.excuteBySql(insertResumSql, new Object[]{(String) FilterVal.init("sys32Id", service).get2(), "course", code, name, pocaDescr, 5, "高级标准课程完成率", seniorNumCompRate, '1', calDate});
	        	service.excuteBySql(insertResumSql, new Object[]{(String) FilterVal.init("sys32Id", service).get2(), "course", code, name, pocaDescr, 6, "技师标准课程完成率", artificerNumCompRate, '1', calDate});
	        	service.excuteBySql(insertResumSql, new Object[]{(String) FilterVal.init("sys32Id", service).get2(), "course", code, name, pocaDescr, 7, "高级技师标准课程完成率", seniorArtificerNumCompRate, '1', calDate});
	        	service.excuteBySql(insertResumSql, new Object[]{(String) FilterVal.init("sys32Id", service).get2(), "course", code, name, pocaDescr, 8, "岗位标准课程完成率", format.format(sumNumRate), '1', calDate});
	        	service.excuteBySql(insertResumSql, new Object[]{(String) FilterVal.init("sys32Id", service).get2(), "course", code, name, pocaDescr, 9, "初级标准课程未完成数", primaryClassNum-finishedPrimaryNum, '1', calDate});
	        	service.excuteBySql(insertResumSql, new Object[]{(String) FilterVal.init("sys32Id", service).get2(), "course", code, name, pocaDescr, 10, "中级标准课程未完成数", middleClassNum-finishedMiddleNum, '1', calDate});
	        	service.excuteBySql(insertResumSql, new Object[]{(String) FilterVal.init("sys32Id", service).get2(), "course", code, name, pocaDescr, 11, "高级标准课程未完成数", seniorClassNum-finishedSeniorNum, '1', calDate});
	        	service.excuteBySql(insertResumSql, new Object[]{(String) FilterVal.init("sys32Id", service).get2(), "course", code, name, pocaDescr, 12, "技师标准课程未完成数", artificerClassNum-finishedArtificerNum, '1', calDate});
	        	service.excuteBySql(insertResumSql, new Object[]{(String) FilterVal.init("sys32Id", service).get2(), "course", code, name, pocaDescr, 13, "高级技师标准课程未完成数", seniorArtificerClassNum-finishedSeniorArtificerNum, '1', calDate});
	        	service.excuteBySql(insertResumSql, new Object[]{(String) FilterVal.init("sys32Id", service).get2(), "course", code, name, pocaDescr, 14, "岗位标准课程未完成总数", (primaryClassNum-finishedPrimaryNum)+(middleClassNum-finishedMiddleNum)+(seniorClassNum-finishedSeniorNum)+(artificerClassNum-finishedArtificerNum)+(seniorArtificerClassNum-finishedSeniorArtificerNum), '1', calDate});
	        	service.excuteBySql(insertResumSql, new Object[]{(String) FilterVal.init("sys32Id", service).get2(), "course", code, name, pocaDescr, 15, "月度计划完成率", format.format((double)finishedClassNum/classNum), '1', calDate});
	         	service.excuteBySql(insertResumSql, new Object[]{(String) FilterVal.init("sys32Id", service).get2(), "course", code, name, pocaDescr, 16, "月度计划未完成课程数量", classNum-finishedClassNum, '1', calDate});
	        
//	         	课时统计信息
	         	service.excuteBySql(insertResumSql, new Object[]{(String) FilterVal.init("sys32Id", service).get2(), "hour", code, name, pocaDescr, 1, "培训总课时数", finishedStHour+finishedUnStHour,'1', calDate});
	         	for(String key:sumYearHourMap.keySet()){
	    			Object value = sumYearHourMap.get(key);
	    			service.excuteBySql(insertResumSql, new Object[]{(String) FilterVal.init("sys32Id", service).get2(), "hour", code, name, pocaDescr, 2, "年度培训总课时数("+key+")", value, '1', calDate});
	    		}
	         	service.excuteBySql(insertResumSql, new Object[]{(String) FilterVal.init("sys32Id", service).get2(), "hour", code, name, pocaDescr, 3, "初级标准课时完成率", primaryHourCompRate,'1', calDate});
	         	service.excuteBySql(insertResumSql, new Object[]{(String) FilterVal.init("sys32Id", service).get2(), "hour", code, name, pocaDescr, 4, "中级标准课时按成率", middleHourCompRate,'1', calDate});
	         	service.excuteBySql(insertResumSql, new Object[]{(String) FilterVal.init("sys32Id", service).get2(), "hour", code, name, pocaDescr, 5, "高级标准课时完成率", seniorHourCompRate,'1', calDate});
	         	service.excuteBySql(insertResumSql, new Object[]{(String) FilterVal.init("sys32Id", service).get2(), "hour", code, name, pocaDescr, 6, "技师标准课时完成率", artificerHourCompRate,'1', calDate});
	         	service.excuteBySql(insertResumSql, new Object[]{(String) FilterVal.init("sys32Id", service).get2(), "hour", code, name, pocaDescr, 7, "高级技师标准课时完成率", seniorArtificerHourCopmRate,'1', calDate});
	         	service.excuteBySql(insertResumSql, new Object[]{(String) FilterVal.init("sys32Id", service).get2(), "hour", code, name, pocaDescr, 8, "岗位标准课时完成率", format.format(sumHourRate),'1', calDate});
	         	service.excuteBySql(insertResumSql, new Object[]{(String) FilterVal.init("sys32Id", service).get2(), "hour", code, name, pocaDescr, 9, "初级标准课时未完成数", (int)(primaryHour-finishedPrimaryHour),'1', calDate});
	         	service.excuteBySql(insertResumSql, new Object[]{(String) FilterVal.init("sys32Id", service).get2(), "hour", code, name, pocaDescr, 10, "中级标准课时未完成数", (int)(middleHour-finishedMiddleHour),'1', calDate});
	         	service.excuteBySql(insertResumSql, new Object[]{(String) FilterVal.init("sys32Id", service).get2(), "hour", code, name, pocaDescr, 11, "高级标准课时未完成数", (int)(seniorHour-finishedSeniorHour),'1', calDate});
	         	service.excuteBySql(insertResumSql, new Object[]{(String) FilterVal.init("sys32Id", service).get2(), "hour", code, name, pocaDescr, 12, "技师标准课时未完成数", (int)(artificerHour-finishedArtificerHour),'1', calDate});
	         	service.excuteBySql(insertResumSql, new Object[]{(String) FilterVal.init("sys32Id", service).get2(), "hour", code, name, pocaDescr, 13, "高级技师标准课时未完成数", (int)(seniorArtificerHour-finishedSeniorArtificerHour),'1', calDate});
	         	service.excuteBySql(insertResumSql, new Object[]{(String) FilterVal.init("sys32Id", service).get2(), "hour", code, name, pocaDescr, 14, "岗位标准课时总未完成数", (int)((primaryHour-finishedPrimaryHour)+(middleHour-finishedMiddleHour)+(seniorHour-finishedSeniorHour)+(artificerHour-finishedArtificerHour)+(seniorArtificerHour-finishedSeniorArtificerHour)),'1', calDate});
	         	service.excuteBySql(insertResumSql, new Object[]{(String) FilterVal.init("sys32Id", service).get2(), "hour", code, name, pocaDescr, 15, "月度计划完成率", format.format((double)(finishedStHour+finishedUnStHour)/(finishedStHour+finishedUnStHour+unFinishedStHour+unFinishedUnStHour)),'1', calDate});
	         	service.excuteBySql(insertResumSql, new Object[]{(String) FilterVal.init("sys32Id", service).get2(), "hour", code, name, pocaDescr, 16, "月度计划未完成课程数量", unFinishedStHour+unFinishedUnStHour,'1', calDate});*/
//	        }
		}
		  service.saveList(resumSaveList);
	}
	
	/**
	 * 完成率累加(课程完成率/课时完成率累加,任一完成率不能为"0")
	 * @param primaryNumCompRate
	 * @param format
	 * @param sumNumRate
	 * @return
	 * @throws ParseException
	 */
	private double calSumRate(String primaryNumCompRate, NumberFormat format, double sumNumRate) throws ParseException {
		if(!StringUtils.equals(primaryNumCompRate, "-")){
			Number pnr = format.parse(primaryNumCompRate);
			sumNumRate +=  pnr.doubleValue();
		}
		return sumNumRate;
	}

	/**
	 * 完成率的计算(已完成数量/总数量,总数量不能为0)
	 * @param finishedNum
	 * @param classNum
	 * @param format
	 * @return
	 */
	private String calCompRate(int finishedNum, int classNum, NumberFormat format) {
		String compRate;
		if(classNum!=0){
			compRate = format.format((double)finishedNum/classNum);
		}else{
			compRate = "-";
		}
		return compRate;
	}
	
	private String calCompRate(double finishedNum, double classNum, NumberFormat format) {
		String compRate;
		if(classNum!=0){
			compRate = format.format((double)finishedNum/classNum);
		}else{
			compRate = "-";
		}
		return compRate;
	}
}
